package lesson01;

import javax.management.monitor.Monitor;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class TestAction {
    public static void main(String[] args) {
        Frame frame=new Frame("开始-停止");
        Button button1 = new Button("start");
        Button button2 = new Button("Stop");
        //可以显示的定义一些东西，如果不定义，则会走默认的值
        button2.setActionCommand("button2-stop");
        MyMonitor myMonitor=new MyMonitor();
//        button1.addActionListener(myMonitor);
        button1.addActionListener((e)-> System.out.println("bbb"));
        button2.addActionListener(myMonitor);
        frame.add(button1,BorderLayout.SOUTH);
        frame.add(button2,BorderLayout.NORTH);
        frame.pack();
        frame.setVisible(true);
    }
}
class MyMonitor implements ActionListener {
    @Override
    public void actionPerformed(ActionEvent e) {
        System.out.println("aaa");
        //可以通过e获取到一些信息
    }
}
